Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poppinss/hash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/hash

Multi driver hash module with support for PHC string formats

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Password hashing

Module to hash values with support for PHC string format

circleci-image npm-image license-image

This module is used by AdonisJs to hash user password with first class support for upgrading logic. A big thanks to the author of uphash, who inspired me to use PHC string format. I would have used uphash directly, but the user facing API is different from what I desire.

Table of contents

Features

  1. Support for multiple hashing algorithms.
  2. Option to extend and add your own hashing algorithms.
  3. Wraps the hash output to a PHC string format, this allows upgrading user passwords, when the underlying configuration changes.

Usage

The bcrypt driver doesn't work with Node v12 yet. We are waiting for bcrypt open issues to get fixed.

Install the package from npm registry as follows:

npm i @poppinss/hash

# yarn
yarn add @poppinss/hash

and then use it as follows:

import { Hash } from '@poppinss/hash'
const hash = new Hash(iocContainer, config)

const hashedValue = await hash.hash('password')
await hash.verify(hashedValue)

await hash.needsRehash(hashedValue) // false

Switching drivers

You can switch drivers using the driver method.

import { Hash } from '@poppinss/hash'
const hash = new Hash(iocContainer, config)

await hash.driver('bcrypt').hash('password')

Adding custom drivers

The custom drivers can be added using the extend method.

import { Hash, HashDriverContract } from '@poppinss/hash'
const hash = new Hash(iocContainer, config)

class Scrypt implements HashDriverContract {}

hash.extend('scrypt', (container) => {
  return new Scrypt()
})

API Docs

Following are the autogenerated files via Typedoc

Maintainers

Harminder virk

Keywords

FAQs

Package last updated on 30 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc